<?php
require 'vendor/autoload.php';

// 初始化应用
$app = new think\App();
$app->initialize();

echo "=== 模拟获取菜单 ===\n\n";

// 模拟登录admin用户
$_SESSION = [];
$_SESSION['user'] = [
    'id' => 10000,
    'username' => 'admin',
    'authorize' => '',
    'status' => 1
];

try {
    // 获取菜单
    $menus = \think\admin\service\MenuService::getTree();
    
    echo "获取到的菜单数量: " . count($menus) . "\n\n";
    
    if (empty($menus)) {
        echo "菜单为空！\n\n";
        
        // 检查是否是超级管理员
        $isSuper = \think\admin\service\AdminService::isSuper();
        echo "是否超级管理员: " . ($isSuper ? '是' : '否') . "\n";
        
        // 检查是否登录
        $isLogin = \think\admin\service\AdminService::isLogin();
        echo "是否已登录: " . ($isLogin ? '是' : '否') . "\n";
        
    } else {
        echo "菜单内容:\n";
        print_r($menus);
    }
    
} catch (\Exception $e) {
    echo "错误: " . $e->getMessage() . "\n";
    echo "堆栈: " . $e->getTraceAsString() . "\n";
}

